{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from xgboost import XGBClassifier\n",
    "import xgboost as xgb\n",
    "\n",
    "import time\n",
    "\n",
    "import numpy as np\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt\n",
    "import pandas as pd\n",
    "\n",
    "from sklearn.metrics import log_loss\n",
    "from sklearn.model_selection import GridSearchCV,StratifiedKFold"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "train = pd.read_csv(\"RentListingInquries_FE_train.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "y_train = train['interest_level']\n",
    "x_train = train.drop(['interest_level'],axis=1)\n",
    "x_train = np.array(x_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#准备交叉验证参数\n",
    "kfold = StratifiedKFold(n_splits=5,shuffle=True,random_state=0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "#初步确定弱学习器数目，这是一个三分类的问题 [2 1 0] 为高、中、低三类。直接调用XGBoost"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "xgb1 = XGBClassifier(\n",
    "    learning_rate=0.1,\n",
    "    n_estimators=1000,\n",
    "    max_depth=5,\n",
    "    min_child_weight=1,\n",
    "    gamma=0,\n",
    "    subsample=0.3,\n",
    "    colsample_bytree=0.8,\n",
    "    colsample_bylevel=0.7,\n",
    "    objective='multi:softprob',\n",
    "    seed=3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "def modelfit(xlg,x_train,y_train,cv_folds=None,early_stopping_rounds=10):\n",
    "    xgb_param = xlg.get_xgb_params()\n",
    "    xgb_param['num_class'] = 3\n",
    "\n",
    "    xgtrain = xgb.DMatrix(x_train, label=y_train)\n",
    "\n",
    "    cvresult = xgb.cv(xgb_param, xgtrain, num_boost_round=xlg.get_params()['n_estimators'], folds=cv_folds,\n",
    "                      metrics='mlogloss', early_stopping_rounds=early_stopping_rounds)\n",
    "    cvresult.to_csv('n_estimators_1.csv', index_label='n_estimators')\n",
    "\n",
    "    n_estimators = cvresult.shape[0]\n",
    "\n",
    "\n",
    "    print(\"n_estimators is \",n_estimators)\n",
    "\n",
    "    xlg.set_params(n_estimators=n_estimators)\n",
    "    xlg.fit(x_train, y_train, eval_metric='mlogloss')\n",
    "\n",
    "    cvresult = pd.DataFrame.from_csv('n_estimators_1.csv')\n",
    "\n",
    "    test_means = cvresult['test-mlogloss-mean']\n",
    "    test_stds = cvresult['test-mlogloss-std']\n",
    "\n",
    "    train_means = cvresult['train-mlogloss-mean']\n",
    "    train_stds = cvresult['train-mlogloss-std']\n",
    "\n",
    "    x_axis = range(0, cvresult.shape[0])\n",
    "\n",
    "    plt.errorbar(x_axis, test_means, yerr=test_stds, label='Test')\n",
    "    plt.errorbar(x_axis, train_means, yerr=train_stds, label=\"Train\")\n",
    "\n",
    "    plt.title(\"XGBoost n_estimators vs Log Loss\")\n",
    "    plt.xlabel('n_estimators')\n",
    "    plt.ylabel('Log Loss')\n",
    "    plt.savefig('n_estimator_1.png')\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time.struct_time(tm_year=2018, tm_mon=5, tm_mday=25, tm_hour=21, tm_min=35, tm_sec=23, tm_wday=4, tm_yday=145, tm_isdst=0)\n",
      "n_estimators is  205\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAA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iOr6j2jcp4GpwCNm9kg07hILFz16ycy+nvH6JjO7zsyeBk40sxvN7OWoB9JvZmeNSt7J\n5unSGjTkeiBcKKULODJ6fDdw6SDTPgQcGN0/Hng4uv8iMC26Xx3dXgZ8P+O1vY8JXSbcReiO4Hyg\nATic8KNrYUYtPd0WJIFHgbnR4xVEFzkiBMQqoBZIAQ8DF0TPOXBRz7wI3UNYZp0aNLzZQVsKsi96\nw92fj+4vJATFTqJui08Cfm3hcow/IlwRC+C/gTvM7BOEL/DhuM/dnRAoG939RQ89gy7OWP5FZvYs\n8BxwGOFqW/0dCzzq7ps9XDTnF4SrhwF0E3rWhBA8bcBPzOxCoGWXOYnshVTcBYhkQXvG/W5goN1H\nCaDe3Y/s/4S7f9LMjgfeDTxvZrtMs5tlpvstPw2kop5APw8c6+7bo91KxQPMZ6C+83u0edSO4O5d\nZnYc4ap0FwNXAacPo06R3dKWguQlDxc1ecPM3g+9F0c/Irq/v7s/7e7XAFsIfdk3Eq6nu7cqgWZg\nh5lNIlwnokfmvJ8GTjWzmqgb50uAx/rPLNrSqXL3B4DPEi5iI/KmaUtB8tmHgB+Y2VeAAkK7wCLg\nJjM7kPCr/aFo3Crg6mhX0w17uiB3X2RmzxF2Jy0n7KLqcSvwJzNb7+7/ZGZfAh6Jlv+Auw90LYsK\n4A9mVhxN9y97WpPIQHRIqoiI9NLuIxER6aXdR7LPM7NbgJP7jf6uu98eRz0io5l2H4mISC/tPhIR\nkV4KBRER6aVQEBGRXgoFERHp9f8A2eD/fPvUqbgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x226902e4f98>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "time.struct_time(tm_year=2018, tm_mon=5, tm_mday=25, tm_hour=21, tm_min=43, tm_sec=13, tm_wday=4, tm_yday=145, tm_isdst=0)\n"
     ]
    }
   ],
   "source": [
    "print(time.localtime(time.time()))\n",
    "modelfit(xgb1, x_train, y_train, cv_folds=kfold)\n",
    "print(time.localtime(time.time()))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "### 初步确定学习器数目为205"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
